<template>
  <div class="wrapper">
    <swiper :options="swiperOption" v-if="showSwiper">
      <swiper-slide v-for="item of list" :key="item.id">
        <img class="swiper-img" :src="item.imgUrl"/>
      </swiper-slide>
      <div class="swiper-pagination"  slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
        autoplay: 3500,
        pagination: '.swiper-pagination'
      }
    }
  },
  computed: {
    showSwiper () {
      return this.list.length
    }
  }
}
</script>

<style lang="stylus" scoped>
  // >>>样式穿透,wrapper下边的这个样式 都让它变成红色
  .wrapper >>> .swiper-pagination-bullet-active
    background #FFFFFF !important
  .wrapper
    overflow hidden
    width 100%
    height 0
    padding-bottom 31.2%
    background #CCC
  .swiper-img
    width 100%
</style>
